<template>
  <view class="my-settle-container">
    <!-- 全选区域 -->
      <label class="radio" >
        <radio color="#c00000" :checked="isFullChecked"  @click="changeAllGoodsState"/><text>全选</text>
      </label>
      
    <!-- 合计区域 -->
    <view class="amount">
      合计 : <text class="money">￥{{checkedGoodsAmount}}</text>
    </view>
    
    <!-- 结算按钮区域 -->
    <view class="btn-amount">
      <text>结算({{checkedCount}})</text>
    </view>
  </view>
</template>

<script>
  import store from '../../store/store.js'
  export default {
    name:"my-settle",
    computed: {
      checkedCount() {
        return store.getters.checkedCount
      },
      total() {
        return store.getters.total
      },
      checkedGoodsAmount() {
        return store.getters.checkedGoodsAmount
      },
      isFullChecked(){
        return this.checkedCount === this.total
      }
    },
    data() {
      return {
        
      };
    },
    methods:{
      // 点击全选按钮修改全部商品状态的方法
      changeAllGoodsState(){
        this.updateAllGoodsState(!this.isFullChecked)
      },
      // 引入Store中的 updateAllGoodsState 方法
      updateAllGoodsState(newState) {
        store.commit('updateAllGoodsState', newState)
      },
    }
  }
</script>

<style lang="scss">
.my-settle-container{
  position: fixed;
  bottom: 0px;
  left: 0px;
  height: 50px;
  width: 100%;
  background-color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  .radio{
    display: flex;
    align-items: center;
    padding-left: 5px;
  }
  .amount{
    .money{
      color: #c00000;
      font-weight: 700;
      font-size: 15px
    }
  }
  .btn-amount{
    height: 50px;
    min-width: 100px;
    background-color: #c00000;
    line-height: 50px;
    text-align: center;
    color: white;
  }
}
</style>